<?php
// +----------------------------------------------------------------------
// | NewThink [ Think More,Think Better! ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2018 http://www.newthink.cc All rights reserved.
// +----------------------------------------------------------------------
// | 版权所有：山西创泰网络科技有限公司
// +----------------------------------------------------------------------
// | Author: JiYun Date:2019-02-28 Time:16:33
// +----------------------------------------------------------------------

namespace app\common\model\airquality;

use app\common\model\BaseModel;
use think\Db;

/**
 * 站点空气质量预报
 * Class AirQualityStationAqiForecastDay
 * @package app\index\model
 */
class AirQualityStationAqiForecastDayModel extends BaseModel
{
    protected $table = 'air_quality_station_aqi_forecast_day';
    
    /**
     * AirQualityStationAqiForecastDay constructor.
     */
    public function __construct()
    {
        parent::__construct();
    }
    
    /**
     * 获取7日数据
     * @author JiYun On 2019/03/04
     * @param array $param
     * @return array|\PDOStatement|string|\think\Collection
     * @throws \Exception
     */
    public function get7DayForecastList($param = [])
    {
        try {
            $sql = sprintf(
                "SELECT
                            *
                        FROM
                            `air_quality_station_aqi_forecast_day`
                        WHERE
                            `region_id` = %d
                            AND `station_id` = %d
                            AND `publish_time` = '%s'
                            AND `predict_time` BETWEEN '%s'
                            AND '%s'",
                $param['city'],
                $param['station'],
                $param['publish_time'],
                $param['start_time'],
                $param['end_time']
            );
            $list = Db::query($sql);
        } catch (\Exception $e) {
            throw $e;
        }
        
        return $list;
    }
}
